1   /*
2    * Copyright (C) 2011 The Guava Authors
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the
10   * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11   * express or implied. See the License for the specific language governing permissions and
12   * limitations under the License.
13   */
14  
15  package com.google.common.collect;
16  
17  import com.google.common.annotations.GwtCompatible;
18  
19  import java.util.Comparator;
20  import java.util.Iterator;
21  
22  /**
23   * An {@code Iterable} whose elements are sorted relative to a {@code Comparator}, typically
24   * provided at creation time.
25   *
26   * @author Louis Wasserman
27   */
28  @GwtCompatible
29  interface SortedIterable<T> extends Iterable<T> {
30    /**
31     * Returns the {@code Comparator} by which the elements of this iterable are ordered, or {@code
32     * Ordering.natural()} if the elements are ordered by their natural ordering.
33     */
34    Comparator<? super T> comparator();
35  
36    /**
37     * Returns an iterator over elements of type {@code T}. The elements are returned in
38     * nondecreasing order according to the associated {@link #comparator}.
39     */
40    @Override
41    Iterator<T> iterator();
42  }